import { createVNode, render } from 'vue'
import message_ from './index.vue'

function Message ({ type, text }) {
  // 1.生成虚拟dom
  const messageVNode = createVNode(message_, { type, text })
  // 2.动态生成一个容器
  const container = document.createElement('div')
  // 3.挂载虚拟dom
  document.body.appendChild(container)
  render(messageVNode, container)
  // 4.一定时间后销毁虚拟dom
  setTimeout(() => {
    render(null, container)
  }, 1500)
}
export default Message
